import React from 'react';
import { inject, observer } from 'mobx-react';
import {toJS} from "mobx";
import {WeaFormItem,WeaSearchGroup} from 'ecCom';
import {WeaSwitch} from 'comsMobx';
import WeaCptTableEdit from '../CapitalTableEdit/WeaCptTableEdit'
import {WeaLocaleProvider} from 'ecCom';
const getLabel = WeaLocaleProvider.getLabel;

@inject('cptInstockStore')
@observer
class InstockAdd extends React.Component {
    constructor(props) {
		super(props);
	} 
    render(){
        const {cptInstockStore} = this.props;
        const { subTableInfo,initInstockData,batchBrowser,isuse } = cptInstockStore;
        return (
            <div>
            <WeaCptTableEdit ecId={`${this && this.props && this.props.ecId || ''}_WeaCptTableEdit@j4pohs`}
                key = { isuse }
                ref = { ref => { cptInstockStore.instockRemind = ref }}
                title={getLabel(83579,"入库明细")}
                showGroup={true}
                needAdd={true}
                needCopy={true}
                columns={toJS(subTableInfo.columnData || {})}
                datas={toJS(initInstockData)}
                datas_0={toJS(subTableInfo.columnDefine || [])}
                onChange={this.editTableDatas.bind(this)}
                batchBrowser={batchBrowser}
            />
            </div>)

    }
    // getFormFields(){
    //     const { mainTableInfo, addForm } = this.props.cptInstockStore;
    //     const {isFormInit} = addForm;
    //     let group = [];
    //     const formParams = addForm.getFormParams();
    //     isFormInit &&  toJS(mainTableInfo).map(c =>{
    //       let items = [];
    //       c.items.map(fields => {
    //         let hide = false;
    //         items.push({
    //             com:(<WeaFormItem
    //                 error={addForm.getError(fields)}
    //                 tipPosition="bottom"
    //                 label={`${fields.label}`}
    //                 labelCol={{span: `${fields.labelcol}`}}
    //                 wrapperCol={{span: `${fields.fieldcol}`}} >
    //                     <WeaSwitch fieldConfig={fields} form={addForm} />
    //                 </WeaFormItem>),
    //             colSpan:1,
    //             hide:hide
    //         });
    //       });
    //       group.push(<WeaSearchGroup needTigger={true} title={c.title} col={2} showGroup={c.defaultshow} items={items}/>)
    //     });
    //     return group;
    // }
    //编辑列表回调
    editTableDatas=(datas)=>{
        const { saveInstockDatas } = this.props.cptInstockStore;
        saveInstockDatas(datas);
    }

}

export default InstockAdd;